import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    name: '登录',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/404',
    name: '404',
    component: () => import('@/views/404'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/',
    name: '装修',
    meta: { title: '装修', icon: 'el-icon-s-marketing' },
    children:[{
      path: '/',
      name: '装修',
      hidden: true,
      component: () => import('@/views/dashboard/admin'),
      meta: { title: '装修', icon: 'el-icon-s-marketing' }
    },
    {
      path: '/share',
      name: '分享装修',
      component: () => import('@/views/draggable/share'),
      meta: { title: '分享装修', icon: 'el-icon-link' }
    }
    ]
  },
  {
    path: '/dashboard',
    component: Layout,
    redirect: '/dashboard/index',
    name: '数据大屏',
    meta: { title: '数据大屏', icon: 'el-icon-s-marketing' },
    children: [{
      path: 'index',
      name: '数据展示',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '数据展示', icon: 'el-icon-s-marketing', keepAlive: true }
    },
    // {
    //   path: 'order',
    //   name: '分红数据',
    //   component: () => import('@/views/dashboard/order'),
    //   meta: { title: '分红数据', icon: 'el-icon-s-marketing' }
    // },
    {
      path: 'business',
      name: '商家数据',
      component: () => import('@/views/dashboard/business'),
      meta: { title: '商家数据', icon: 'el-icon-s-marketing' }
    },
      {
        path: 'qushi',
        name: '茶果趋势',
        component: () => import('@/views/dashboard/qushi'),
        meta: { title: '茶果趋势', icon: 'el-icon-s-marketing' }
      },

    ]
  },
  {
    path: '/audit',
    component: Layout,
    redirect: '/audit/index',
    name: '审核',
    meta: { title: '审核', icon: 'el-icon-s-marketing' },
    children: [{
      path: 'index',
      name: '茶有圈',
      component: () => import('@/views/audit/essay.vue'),
      meta: { title: '茶有圈', icon: 'el-icon-chat-line-square', keepAlive: true }
    },

    ]
  },

  {
    path: '/home',
    component: Layout,
    redirect: '/home/banner',
    name: '公告配置',
    meta: { title: '公告配置', icon: 'el-icon-chat-line-round' },
    children: [
      {
        path: 'banner',
        name: '轮播/广告',
        component: () => import('@/views/home/banner'),
        meta: { title: '轮播/广告', icon: 'el-icon-s-help', keepAlive: true }
      },
      // {
      //   path: 'navigation',
      //   name: '导航',
      //   component: () => import('@/views/home/navigation'),
      //   meta: { title: '导航', icon: 'el-icon-chat-square' }
      // },
      {
        path: 'notice',
        name: '公告',
        component: () => import('@/views/home/notice'),
        meta: { title: '公告', icon: 'el-icon-message-solid', keepAlive: true }
      }
      // ,
      // {
      //   path: 'video',
      //   name: '视频/介绍',
      //   component: () => import('@/views/home/video'),
      //   meta: { title: '视频/介绍', icon: 'el-icon-message-solid' }
      // }
    ]
  },
  // {
  //   path: '/information',
  //   component: Layout,
  //   redirect: '/information/information',
  //   name: '资讯管理',
  //   meta: { title: '资讯管理', icon: 'el-icon-s-platform' },
  //   children: [
  //     {
  //       path: 'information',
  //       name: '资讯列表',
  //       component: () => import('@/views/information/information'),
  //       meta: { title: '资讯列表', icon: 'el-icon-s-platform' }
  //     },
  //     {
  //       path: 'navigation',
  //       name: '栏目管理',
  //       component: () => import('@/views/information/navigation'),
  //       meta: { title: '栏目管理', icon: 'el-icon-menu' }
  //     }

  //   ]
  // },
  {
    path: '/business',
    component: Layout,
    redirect: '/business/information',
    name: '商家管理',
    meta: { title: '商家管理', icon: 'el-icon-s-shop' },
    children: [
      {
        path: 'banner',
        name: '商家轮播',
        component: () => import('@/views/home/banner'),
        meta: { title: '商家轮播', icon: 'el-icon-s-help', keepAlive: true }
      },
      {
        path: 'information',
        name: '商家类型',
        component: () => import('@/views/business/merchantType'),
        meta: { title: '商家类型', icon: 'el-icon-s-shop' }
      },
      {
        path: 'merchantManagement',
        name: '商家列表',
        component: () => import('@/views/business/merchantManagement'),
        meta: { title: '商家列表', icon: 'el-icon-s-shop', keepAlive: true  }
      },
      {
        path: 'merchantManagements',
        name: '冻结商家',
        component: () => import('@/views/business/merchantManagements'),
        meta: { title: '冻结商家', icon: 'el-icon-s-shop' , keepAlive: true }
      },

      {
        path: 'businessDetail',
        name: '商家详情',
        hidden: true,
        component: () => import('@/views/business/businessDetail'),
        meta: { title: '商家详情', icon: 'el-icon-s-shop', keepAlive: true }
      },

      {
        path: 'goodslist',
        name: '商品列表',
        component: () => import('@/views/business/goodslist'),
        meta: { title: '商品列表', icon: 'el-icon-files', keepAlive: true }
      },
      {
        path: 'goodsDetail',
        name: '商品详情',
        hidden: true,
        component: () => import('@/views/business/goodsDetail'),
        meta: { title: '添加商品', icon: 'el-icon-shopping-bag-1' }
      },
      {
        path: 'order',
        name: '商家订单',
        component: () => import('@/views/business/order'),
        meta: { title: '商家订单', icon: 'el-icon-shopping-bag-1', keepAlive: true }
      },
      {
        path: 'orderDetails',
        name: '商家订单详情',
        hidden: true,
        component: () => import('@/views/business/orderDetails'),
        meta: { title: '商家订单详情', icon: 'el-icon-shopping-bag-1',}
      }
    ]
  },

  {
    path: '/commodity',
    component: Layout,
    redirect: '/commodity/partition',
    name: '商品管理',
    meta: { title: '商品管理', icon: 'el-icon-goods' },
    children: [
      {
        path: 'partition',
        name: '分区管理',
        component: () => import('@/views/commodity/partition'),
        meta: { title: '分区管理', icon: 'el-icon-c-scale-to-original', keepAlive: true }
      },
      {
        path: 'primaryclassification',
        name: '一级分类',
        component: () => import('@/views/commodity/primaryclassification'),
        meta: { title: '一级分类', icon: 'el-icon-s-grid', keepAlive: true }
      },
      {
        path: 'secondaryclassification',
        name: '二级分类',
        component: () => import('@/views/commodity/secondaryclassification'),
        meta: { title: '二级分类', icon: 'el-icon-s-grid', keepAlive: true }
      },
      // {
      //   path: 'threelevelclassification',
      //   name: '三级分类',
      //   component: () => import('@/views/commodity/threelevelclassification'),
      //   meta: { title: '三级分类', icon: 'el-icon-s-grid' }
      // },
      {
        path: 'specifications',
        name: '商品规格',
        component: () => import('@/views/commodity/specifications'),
        meta: { title: '商品规格', icon: 'el-icon-discount', keepAlive: true }
      },
      {
        path: 'goodslist',
        name: '商品列表',
        component: () => import('@/views/commodity/goodslist'),
        meta: { title: '商品列表', icon: 'el-icon-shopping-bag-1', keepAlive: true }
      },
      {
        path: 'freight',
        name: '运费模版',
        component: () => import('@/views/commodity/freight'),
        meta: { title: '运费模版', icon: 'el-icon-shopping-bag-1', keepAlive: true }
      },
      {
        path: 'freightList',
        name: '模版设置',
        component: () => import('@/views/commodity/freightList'),
        meta: { title: '模版设置  ', icon: 'el-icon-shopping-bag-1', keepAlive: true }
      },

      {
        path: 'addgoods',
        name: '添加商品',
        hidden: true,
        component: () => import('@/views/commodity/addgoods'),
        meta: { title: '添加商品', icon: 'el-icon-shopping-bag-1', }
      },
      {
        path: 'network',
        name: '网点管理',
        component: () => import('@/views/network/network'),
        meta: { title: '网点管理', icon: 'el-icon-shopping-bag-1', keepAlive: true }
      },


    ]
  },
  // {
  //   path: '/activity',
  //   component: Layout,
  //   redirect: '/activity/partition',
  //   name: '活动列表',
  //   meta: { title: '活动列表', icon: 'el-icon-goods' },
  //   children: [
  //     {
  //       path: 'seckillset',
  //       name: '秒杀设置',
  //       component: () => import('@/views/activity/seckill/seckillset'),
  //       meta: { title: '秒杀设置', icon: 'el-icon-shopping-bag-1' }
  //     },
  //     {
  //       path: 'seckilllist',
  //       name: '秒杀列表',
  //       component: () => import('@/views/activity/seckill/seckilllist'),
  //       meta: { title: '秒杀列表', icon: 'el-icon-shopping-bag-1' }
  //     },
  //     {
  //       path: 'Teamwork',
  //       name: '拼团商品列表',
  //       component: () => import('@/views/activity/Teamwork'),
  //       meta: { title: '拼团商品列表', icon: 'el-icon-shopping-bag-1' }
  //     },
  //     {
  //       path: 'bargaininglist',
  //       name: '砍价商品列表',
  //       component: () => import('@/views/activity/bargaininglist'),
  //       meta: { title: '砍价商品列表', icon: 'el-icon-shopping-bag-1' }
  //     },
  //     // {
  //     //   path: 'coupon',
  //     //   name: '优惠卷',
  //     //   component: () => import('@/views/activity/coupon'),
  //     //   meta: { title: '优惠卷', icon: 'el-icon-shopping-bag-1' }
  //     // }
  //   ]
  // },
  {
    path: '/order',
    component: Layout,
    redirect: '/order/order',
    name: '订单管理',
    meta: { title: '订单管理', icon: 'el-icon-s-order' },
    children: [
      {
        path: 'order',
        name: '订单列表',
        component: () => import('@/views/order/order'),
        meta: { title: '订单列表', icon: 'el-icon-s-order', keepAlive: true }
      },
      // {
      //   path: 'kfcorder',
      //   name: 'KFC订单列表',
      //   component: () => import('@/views/order/kfc/kfcorder'),
      //   meta: { title: 'KFC订单列表', icon: 'el-icon-s-order' }
      // },
      // {
      //   path: 'cotticoffeeorder',
      //   name: '库迪订单列表',
      //   component: () => import('@/views/order/cotticoffee/cotticoffeeorder'),
      //   meta: { title: '库迪订单列表', icon: 'el-icon-s-order' }
      // },
      // {
      //   path: 'luckincoffeeorder',
      //   name: '瑞辛订单列表',
      //   component: () => import('@/views/order/luckincoffee/luckincoffeeorder'),
      //   meta: { title: '瑞辛订单列表', icon: 'el-icon-s-order' }
      // },
      // {
      //   path: 'mcdorder',
      //   name: '麦当劳订单列表',
      //   component: () => import('@/views/order/mcd/mcdorder'),
      //   meta: { title: '麦当劳订单列表', icon: 'el-icon-s-order' }
      // },
      // {
      //   path: 'nayukiorder',
      //   name: '奈雪订单列表',
      //   component: () => import('@/views/order/nayuki/nayukiorder'),
      //   meta: { title: '奈雪订单列表', icon: 'el-icon-s-order' }
      // },
      // {
      //   path: 'pizzahutorder',
      //   name: '必胜客订单列表',
      //   component: () => import('@/views/order/pizzahut/pizzahutorder'),
      //   meta: { title: '必胜客订单列表', icon: 'el-icon-s-order' }
      // },
      // {
      //   path: 'starbucksorder',
      //   name: '星巴克订单列表',
      //   component: () => import('@/views/order/starbucks/starbucksorder'),
      //   meta: { title: '星巴克订单列表', icon: 'el-icon-s-order' }
      // },
      {
        path: 'refundsList',
        name: '售后订单',
        component: () => import('@/views/order/refundsList'),
        meta: { title: '售后订单', icon: 'el-icon-s-order', keepAlive: true }
      },

      {
        path: 'orderDetails',
        name: '订单详情',
        hidden: true,
        component: () => import('@/views/order/orderDetails'),
        meta: { title: '订单详情', icon: 'el-icon-shopping-bag-1',  }
      },

      {
        path: 'kfcDetails',
        name: '订单详情',
        hidden: true,
        component: () => import('@/views/order/kfc/kfcDetails'),
        meta: { title: '订单详情', icon: 'el-icon-shopping-bag-1', }
      },

      {
        path: 'cotticoffeeDetails',
        name: '订单详情',
        hidden: true,
        component: () => import('@/views/order/cotticoffee/cotticoffeeDetails'),
        meta: { title: '订单详情', icon: 'el-icon-shopping-bag-1', keepAlive: true }
      },
      {
        path: 'luckincoffeeDetails',
        name: '订单详情',
        hidden: true,
        component: () => import('@/views/order/luckincoffee/luckincoffeeDetails'),
        meta: { title: '订单详情', icon: 'el-icon-shopping-bag-1', keepAlive: true }
      },
      {
        path: 'mcdDetails',
        name: '订单详情',
        hidden: true,
        component: () => import('@/views/order/mcd/mcdDetails'),
        meta: { title: '订单详情', icon: 'el-icon-shopping-bag-1', keepAlive: true }
      },
      {
        path: 'nayukiDetails',
        name: '订单详情',
        hidden: true,
        component: () => import('@/views/order/nayuki/nayukiDetails'),
        meta: { title: '订单详情', icon: 'el-icon-shopping-bag-1', keepAlive: true }
      },
      {
        path: 'pizzahutDetails',
        name: '订单详情',
        hidden: true,
        component: () => import('@/views/order/pizzahut/pizzahutDetails'),
        meta: { title: '订单详情', icon: 'el-icon-shopping-bag-1', keepAlive: true }
      },
      {
        path: 'starbucksDetails',
        name: '订单详情',
        hidden: true,
        component: () => import('@/views/order/starbucks/starbucksDetails'),
        meta: { title: '订单详情', icon: 'el-icon-shopping-bag-1', keepAlive: true }
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    redirect: '/user/userlist',
    name: '用户管理',
    meta: { title: '用户管理', icon: 'el-icon-s-custom' },
    children: [
      {
        path: 'userlist',
        name: '用户列表',
        component: () => import('@/views/user/userlist'),
        meta: { title: '用户列表', icon: 'el-icon-user-solid', keepAlive: true }
      },
      {
        path: 'team',
        name: '团队结构',
        component: () => import('@/views/user/team'),
        meta: { title: '团队结构', icon: 'el-icon-user', keepAlive: true }
      },
      {
        path: 'level',
        name: '会员级别',
        component: () => import('@/views/user/level'),
        meta: { title: '会员级别', icon: 'el-icon-medal-1', keepAlive: true }
      },
      // {
      //   path: 'department',
      //   name: '部门管理',
      //   component: () => import('@/views/user/department'),
      //   meta: { title: '部门管理', icon: 'el-icon-medal-1' }
      // }

    ]
  },
  {
    path: '/finance',
    component: Layout,
    redirect: '/finance/wallet',
    name: '财务管理',
    meta: { title: '财务管理', icon: 'el-icon-s-finance' },
    children: [
      {
        path: 'wallet',
        name: '钱包记录',
        component: () => import('@/views/finance/wallet'),
        meta: { title: '钱包记录', icon: 'el-icon-s-finance', keepAlive: true }
      },
      {
        path: 'walletmodify',
        name: '钱包修改记录',
        component: () => import('@/views/finance/walletmodify'),
        meta: { title: '钱包修改记录', icon: 'el-icon-s-finance', keepAlive: true }
      },
      {
        path: 'businesswallet',
        name: '商家记录',
        component: () => import('@/views/finance/businesswallet'),
        meta: { title: '商家记录', icon: 'el-icon-s-finance', keepAlive: true }
      },
      {
        path: 'cashRecordRecords',
        name: '其他记录',
        component: () => import('@/views/finance/cashRecordRecords'),
        meta: { title: '其他记录', icon: 'el-icon-s-finance', keepAlive: true }
      },

      {
        path: 'setwallet',
        name: '钱包配置',
        component: () => import('@/views/finance/setwallet'),
        meta: { title: '钱包配置', icon: 'el-icon-set-up', keepAlive: true }
      },
      {
        path: 'reward',
        name: '奖励配置',
        component: () => import('@/views/finance/reward'),
        meta: { title: '奖励配置', icon: 'el-icon-set-up', keepAlive: true }
      },
      {
        path: 'reward2',
        name: '底池设置',
        component: () => import('@/views/finance/reward2'),
        meta: { title: '底池设置', icon: 'el-icon-set-up', keepAlive: true }
      },
      // {
      //   path: 'release',
      //   name: '释放设置',
      //   component: () => import('@/views/finance/release'),
      //   meta: { title: '释放设置', icon: 'el-icon-set-up', keepAlive: true }
      // },
      {
        path: 'wxList',
        name: '微信扫码设置',
        component: () => import('@/views/finance/wxList'),
        meta: { title: '微信扫码设置', icon: 'el-icon-set-up', keepAlive: true }
      },


      // {
      //   path: 'kfcsetwallet',
      //   name: '茶花配置',
      //   component: () => import('@/views/finance/kfcsetwallet'),
      //   meta: { title: '茶花配置', icon: 'el-icon-set-up' }
      // }

    ]
  },
  // {
  //   path: '/message',
  //   component: Layout,
  //   redirect: '/message/message',
  //   name: '消息管理',
  //   meta: { title: '消息管理', icon: 'el-icon-s-order' },
  //   children: [
  //     {
  //       path: 'message',
  //       name: '消息模版',
  //       component: () => import('@/views/message/message'),
  //       meta: { title: '消息模版', icon: 'el-icon-s-grid' }
  //     },
  //     {
  //       path: 'messageAll',
  //       name: '手动消息',
  //       component: () => import('@/views/message/messageAll'),
  //       meta: { title: '手动消息', icon: 'el-icon-s-grid' }
  //     },

  //   ]
  // },
  {
    path: '/setup',
    component: Layout,
    redirect: '/setup/api',
    name: '系统设置',
    meta: { title: '系统设置', icon: 'el-icon-s-tools' },
    children: [
      {
        path: 'api',
        name: 'api管理',
        component: () => import('@/views/setup/api'),
        meta: { title: 'api管理', icon: 'el-icon-link', keepAlive: true }
      },
      {
        path: 'administrators',
        name: '管理员',
        component: () => import('@/views/setup/administrators'),
        meta: { title: '管理员', icon: 'el-icon-user-solid', keepAlive: true }
      },
      {
        path: 'customerSet',
        name: '客服中心',
        component: () => import('@/views/setup/customerSet'),
        meta: { title: '客服中心', icon: 'el-icon-service', keepAlive: true }
      },
      // {
      //   path: 'allocation',
      //   name: '利润分配',
      //   component: () => import('@/views/setup/allocation'),
      //   meta: { title: '利润分配', icon: 'el-icon-set-up' }
      // },
      {
        path: 'agreement',
        name: '协议管理',
        component: () => import('@/views/setup/agreement'),
        meta: { title: '协议管理', icon: 'el-icon-reading', keepAlive: true }
      },
      {
        path: 'tailPage',
        name: '尾页管理',
        component: () => import('@/views/setup/tailPage'),
        meta: { title: '尾页管理', icon: 'el-icon-reading', keepAlive: true }
      },
      //
      // {
      //   path: 'setcash',
      //   name: '用户转账到星链卡',
      //   component: () => import('@/views/setup/setcash'),
      //   meta: { title: '用户转账到星链卡', icon: 'el-icon-s-finance' }
      // },
      {
        path: 'setcashshop',
        name: '商家提现',
        component: () => import('@/views/setup/setcashshop'),
        meta: { title: '商家提现', icon: 'el-icon-sell', keepAlive: true }
      },
      // {
      //   path: 'getcash',
      //   name: '用户转账星链卡审核',
      //   component: () => import('@/views/setup/getcash'),
      //   meta: { title: '用户转账星链卡审核', icon: 'el-icon-sold-out' }
      // },
      {
        path: 'getShopcash',
        name: '商家提现审核',
        component: () => import('@/views/setup/getShopcash'),
        meta: { title: '商家提现审核', icon: 'el-icon-sold-out', keepAlive: true }
      },
      {
        path: 'configuration',
        name: '系统配置',
        component: () => import('@/views/setup/configuration'),
        meta: { title: '系统配置', icon: 'el-icon-s-tools', keepAlive: true }
      },
      {
        path: 'setpay',
        name: '微信支付',
        component: () => import('@/views/setup/setpay'),
        meta: { title: '微信支付', icon: 'el-icon-s-tools', keepAlive: true }
      },
      {
        path: 'zhifubaoset',
        name: '支付宝支付',
        component: () => import('@/views/setup/zhifubaoset'),
        meta: { title: '支付宝支付', icon: 'el-icon-s-tools', keepAlive: true }
      },
      {
        path: 'settlementSet',
        name: '三方接口设置',
        component: () => import('@/views/setup/settlementSet'),
        meta: { title: '三方接口设置', icon: 'el-icon-s-tools', keepAlive: true }
      },

      {
        path: 'menu',
        name: '前端路由',
        component: () => import('@/views/setup/menu'),
        meta: { title: '前端路由', icon: 'el-icon-paperclip', keepAlive: true }
      },
      {
        path: 'signIn',
        name: '签到设置',
        component: () => import('@/views/setup/signIn'),
        meta: { title: '签到设置', icon: 'el-icon-s-tools', keepAlive: true }
      },
      {
        path: 'transferSet',
        name: '转账设置',
        component: () => import('@/views/setup/transferSet'),
        meta: { title: '转账设置', icon: 'el-icon-s-tools', keepAlive: true }
      },
      {
        path: 'modifyPassword',
        name: '修改密码',
        component: () => import('@/views/setup/modifyPassword'),
        meta: { title: '修改密码', icon: 'el-icon-unlock', keepAlive: true }
      },
      {
        path: 'refundsAddress',
        name: '退货地址',
        component: () => import('@/views/setup/refundsAddress'),
        meta: { title: '退货地址', icon: 'el-icon-map-location', keepAlive: true }
      }

    ]
  },


  // {//外链
  //   path: 'external-link',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
  //       meta: { title: 'External Link', icon: 'link' }
  //     }
  //   ]
  // },

  // 404 page must be placed at the end !!!
  // { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
